package com.hw.one.dam2.controller;

import com.hw.one.core.result.MsgResult;
import com.hw.one.dam2.common.DamConstant;
import com.hw.one.dam2.common.SiteTypeEnum;
import com.hw.one.dam2.service.IAlarmInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Copyright 2017 汉威.智慧环保事业部.
 * Created by 李亚坤 on 2017/05/08 10:55.
 * 报警信息控制类
 */
@RestController
@RequestMapping(value = "alarmInformation")
public class AlarmInformationController {

    @Autowired
    private IAlarmInformationService alarmInformationService;

    /**
     * 查询国控站5分钟数据突高报警
     * @author 李亚坤
     * @createtime 2017年5月8日11:01:33
     * @param request
     * @return
     */
    @RequestMapping(value = "/fiveDataSuddenHighAlarm", method = RequestMethod.GET)
    public MsgResult fiveDataSuddenHighAlarm(HttpServletRequest request) {
        try {
            String pointType = request.getParameter("pointType");
            if (StringUtils.isEmpty(pointType)) {
                pointType = SiteTypeEnum.ALL_AIR_SITE.getValue();
            }
            Map<String, Object> paramMap = new HashMap<>();
            paramMap.put("pointType", pointType);
            Object obj = alarmInformationService.fiveDataSuddenHighAlarm(paramMap);

            return MsgResult.okResult(obj);
        }catch (Exception e) {
            e.printStackTrace();
            return MsgResult.errorResult("查询5分钟报警信息异常，后台异常。");
        }
    }
}
